<template>
  <div>
    <el-row>
      <el-col :span="1">
        <el-form-item>
          <el-switch v-model="value" active-color="#13ce66" inactive-color="#999"></el-switch>
        </el-form-item>
      </el-col>
      <el-col :span="20">
        <el-form-item style="margin-left:100px" label="游玩日期前">
          <el-form :inline="true" label=":" class="demo-form-inline">
            <el-form-item label>
              <el-input
                style="width: 80px"
                v-model="singleTicketRefundRule.beforeStandardDays"
                placeholder="天"
              ></el-input>
            </el-form-item>
            <el-form-item label="天">
              <el-input
                style="width: 80px"
                v-model="singleTicketRefundRule.beforeStandardHours"
                placeholder="时"
              ></el-input>
            </el-form-item>
            <el-form-item label="时">
              <el-input
                style="width: 80px"
                v-model="singleTicketRefundRule.beforeStandardMinutes"
                placeholder="分"
              ></el-input>
            </el-form-item>
            <el-form-item label="分以内,扣费">
              <el-input
                style="width: 80px"
                v-model="singleTicketRefundRule.deduction"
                placeholder="分"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-select style="width: 80px" v-model="singleTicketRefundRule.refundType">
                <el-option
                  v-for="item in deductions"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-button v-if="index==indexlength" type="primary" @click="reduce">-</el-button>
          </el-form>
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "",
  props: {
    index: {
      type: Number,
      default: ""
    },
    indexlength: {
      type: Number,
      default: ""
    }
  },
  data() {
    return {
      value: false,
      deductions: [
        { id: 1, title: "元" },
        { id: 2, title: "%" }
      ],
      singleTicketRefundRule: {
        hotelRoomCode: this.roomCode,
        beforeStandardDays: 2,
        beforeStandardHours: 0,
        beforeStandardMinutes: 0,
        refundType: "",
        deduction: "50"
      }
    };
  },
  watch: {
    value: function(newvalue, oldvalue) {
      if (newvalue == true) {
        let obj = {};
        obj.index = this.index + 1;
        obj.data = this.singleTicketRefundRule;
        this.$emit("addinfo", obj);
      } else {
        // this.singleTicketRefundRule = {};
        
        this.$emit("addinfo", this.index + 1);
      }
    }
  },
  methods: {
    reduce: function() {
      this.$emit("addindex");
    }
  }
};
</script>

<style lang="" scoped>
</style>